]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
windowPreview: Ensure scaling is limited to defined size increase
authorSebastian Keller <skeller@gnome.org>
Sun, 21 Feb 2021 17:38:05 +0000 (18:38 +0100)
committerMarge Bot <marge-bot@gnome.org>
Wed, 24 Feb 2021 09:58:31 +0000 (09:58 +0000)
The preview was getting scaled up by a factor based on what is needed to
increase the width by activeExtraSize pixels. With windows that are
wider than than they are tall, this means that the size of the window
will not increase any more than activeExtraSize in any direction, but
for windows that are taller than they are wide, the vertical scaling
can exceed this. This would break some of the assumptions in the
reported size for the preview chrome and could for very narrow windows
result in a rather large scale.

To fix this, calculate the scaling factor based on whatever is larger,
the height or the width.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1707>

js/ui/windowPreview.js

index 1659d0077548056865a89b41bec3c3106f050170..a27d0586f46d04f9de07e8891e431f05adbef37e 100644 (file)
@@ -528,10 +528,11 @@ var WindowPreview = GObject.registerClass({
             });
         });
 
-        const { width } = this._windowContainer;
+        const [width, height] = this._windowContainer.get_size();
         const { scaleFactor } = St.ThemeContext.get_for_stage(global.stage);
         const activeExtraSize = WINDOW_ACTIVE_SIZE_INC * 2 * scaleFactor;
-        const scale = (width + activeExtraSize) / width;
+        const origSize = Math.max(width, height);
+        const scale = (origSize + activeExtraSize) / origSize;
 
         this._windowContainer.ease({
             scale_x: scale,